package SpringFramework.Java配置;

import org.springframework.context.annotation.AnnotationConfigApplicationContext;

import SpringFramework.Java配置.config.JavaConfig;
import SpringFramework.Java配置.service.UseFunctionService;

public class Main {

	public static void main(String[] args) {
		AnnotationConfigApplicationContext context = null;
		try {
			// 使用AnnotationConfigApplicationContext作为Spring容器，接受输入一个配置类作为参数。
			context = new AnnotationConfigApplicationContext(JavaConfig.class);
			// 获得声明配置的UseFunctionService的Bean
			UseFunctionService useFunctionService = context.getBean(UseFunctionService.class);
			System.out.println(useFunctionService.sayHello("java config"));
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			if(context!=null) {
				context.close();
			}
		}
	}

}
